package 使用元注解自定义文档注解;

import java.lang.annotation.*;

// 自定义文档注解
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
@interface ClassPreamble {
    String author();
    String date();
    int currentRevision() default 1;
    String lastModified() default "N/A";
    String[] reviewers();
}

// 使用自定义文档注解
@ClassPreamble(
    author = "John Doe",
    date = "3/17/2023",
    currentRevision = 6,
    lastModified = "4/12/2023",
    reviewers = {"Alice", "Bob", "Cindy"}
)
class DocumentedClass {
}

public class AnnotationDemo3 {
    public static void main(String[] args) {
        // 获取类上的注解信息
        ClassPreamble preamble = DocumentedClass.class.getAnnotation(ClassPreamble.class);
        
        System.out.println("作者: " + preamble.author());
        System.out.println("日期: " + preamble.date());
        System.out.println("版本: " + preamble.currentRevision());
        System.out.println("最后修改: " + preamble.lastModified());
        System.out.println("评审人: " + String.join(", ", preamble.reviewers()));
    }
}